package model.board;

public class PagingBean {
	private int totalContent;
	private int nowPage=1;
	private boolean isSearch=false; // 검색한 내용이면 true 그냥 게시판 보기이면 false
	public int getNowPage() {
		return nowPage;
	}
	public boolean getIsSearch(){
		return isSearch;
	}
	private int numberOfContentPerPage=CommonConstants.CONTENT_NUMBER_PER_PAGE;
	private int numberOfPageGroup=CommonConstants.PAGEGROUP_NUMBER_PER_PAGE;
	public PagingBean(int totalContent, int nowPage) {
		super();
		this.totalContent = totalContent;
		this.nowPage = nowPage;
	}
	public PagingBean(int totalContent, int nowPage, int numberOfContentPerPage) {
		super();
		this.totalContent = totalContent;
		this.nowPage = nowPage;
		this.numberOfContentPerPage=numberOfContentPerPage;
	}
	public PagingBean(int totalContent, int nowPage, int numberOfContentPerPage, boolean isSearch) {
		super();
		this.totalContent = totalContent;
		this.nowPage = nowPage;
		this.numberOfContentPerPage=numberOfContentPerPage;
		this.isSearch = isSearch;
	}
	public int getNumberOfContentPerPage() {
		return numberOfContentPerPage;
	}
	public int getTotalPage(){
		int num=totalContent%this.numberOfContentPerPage;
		int totalPage=0;
		if(num==0)
			totalPage=totalContent/this.numberOfContentPerPage;
		else
			totalPage=totalContent/this.numberOfContentPerPage+1;
		return totalPage;
	}
	public int getTotalPageGroup(){
		int num=this.getTotalPage()%this.numberOfPageGroup;
		int totalGroup=0;
		if(num==0)
			totalGroup=this.getTotalPage()/this.numberOfPageGroup;
		else
			totalGroup=this.getTotalPage()/this.numberOfPageGroup+1;
		return totalGroup;
	}
	public int getNowPageGroup(){
		int num=this.nowPage%this.numberOfPageGroup;
		int nowGroup=0;
		if(num==0)
			nowGroup=this.nowPage/this.numberOfPageGroup;
		else
			nowGroup=this.nowPage/this.numberOfPageGroup+1;
		return nowGroup;
	}
	public int getStartPageOfPageGroup(){
		int start=this.numberOfPageGroup*(this.getNowPageGroup()-1)+1;
		return start;
	}
	public int getEndPageOfPageGroup(){
		int end=this.numberOfPageGroup*this.getNowPageGroup();
		if(end>this.getTotalPage()){
			end=this.getTotalPage();
		}
		return end;
	}
	public boolean isPreviousPageGroup(){
		boolean flag=false;
		if(this.getNowPageGroup()>1)
			flag=true;
		return flag;
	}
	public boolean isNextPageGroup(){
		boolean flag=false;
		if(this.getNowPageGroup()<this.getTotalPageGroup())
			flag=true;
		return flag;
	}
	@Override
	public String toString() {
		return "PagingBean [totalContent=" + totalContent + ", nowPage="
				+ nowPage + ", isSearch=" + isSearch
				+ ", numberOfContentPerPage=" + numberOfContentPerPage
				+ ", numberOfPageGroup=" + numberOfPageGroup + "]";
	}
	
}











